package org.scirp.ijmis.service.personpaper.impl;

import java.util.List;

import org.scirp.ijmis.dao.personpaper.ISurveyChoiceOfPersonDAO;
import org.scirp.ijmis.po.personpaper.SurveyChoiceOfPerson;
import org.scirp.ijmis.service.personpaper.ISurveyChoiceOfPersonService;

public class SurveyChoiceOfPersonServiceImpl implements ISurveyChoiceOfPersonService {
	private ISurveyChoiceOfPersonDAO surveyChoiceOfPersonDAO; 
	@Override
	public Long countObject() {
		return surveyChoiceOfPersonDAO.countObject();
	}

	@Override
	public SurveyChoiceOfPerson deleteSurveyChoiceOfPerson(SurveyChoiceOfPerson surveyChoiceOfPerson) {
		return surveyChoiceOfPersonDAO.deleteSurveyChoiceOfPerson(surveyChoiceOfPerson);
	}

	@Override
	public long saveSurveyChoiceOfPerson(SurveyChoiceOfPerson surveyChoiceOfPerson) {
		return surveyChoiceOfPersonDAO.saveSurveyChoiceOfPerson(surveyChoiceOfPerson);
	}

	@Override
	public List<SurveyChoiceOfPerson> selectAll() {
		return surveyChoiceOfPersonDAO.selectAll();
	}

	@Override
	public SurveyChoiceOfPerson selectById(Object id) {
		return surveyChoiceOfPersonDAO.selectById(id);
	}

	@Override
	public List<SurveyChoiceOfPerson> selectSurveyChoiceOfPersonByPersonId(Long personId) {
		return surveyChoiceOfPersonDAO.selectSurveyChoiceOfPersonByPersonId(personId);
	}

	@Override
	public List<SurveyChoiceOfPerson> selectSurveyChoiceOfPersonBySurveyChoiceId(Long surveyChoiceId) {
		return surveyChoiceOfPersonDAO.selectSurveyChoiceOfPersonBySurveyChoiceId(surveyChoiceId);
	}

	@Override
	public boolean updateSurveyChoiceOfPerson(SurveyChoiceOfPerson entity) {
		return surveyChoiceOfPersonDAO.updateSurveyChoiceOfPerson(entity);
	}
	public boolean updateSurveyChoiceOfPerson(List<SurveyChoiceOfPerson> surveyChoiceOfPersons) {
		boolean flag=true;
		for (SurveyChoiceOfPerson surveyChoiceOfPerson : surveyChoiceOfPersons) {
			if(!surveyChoiceOfPersonDAO.updateSurveyChoiceOfPerson(surveyChoiceOfPerson)){
				flag=false;
			}
		}
		return flag;
	}
	public boolean updateSurveyChoiceOfPerson(Long personId,List<Long> surveyIds,List<SurveyChoiceOfPerson> surveyChoiceOfPersons){
		boolean flag=true;
		for (Long surveyId : surveyIds) {
			if(surveyChoiceOfPersonDAO.deleteSurveyChoiceOfPersonByPersonIdAndSureyId(personId,surveyId)){
				flag=flag&&true;
			}
		}
		for (SurveyChoiceOfPerson surveyChoiceOfPerson : surveyChoiceOfPersons) {
			flag=flag&surveyChoiceOfPersonDAO.updateSurveyChoiceOfPerson(surveyChoiceOfPerson);
		
	}
		return flag;
	}
	@Override
	public boolean deleteSurveyChoiceOfPersonByPersonId(Long personId) {
		return surveyChoiceOfPersonDAO.deleteSurveyChoiceOfPersonByPersonId(personId);
	}
	
	@Override
	public Long countObjectByChoiceId(Long ChoiceId) {
		return surveyChoiceOfPersonDAO.countObjectByChoiceId(ChoiceId);
	}
	
	@Override
	public Long countObjectBySurveyId(Long surveyId) {
		return surveyChoiceOfPersonDAO.countObjectBySurveyId(surveyId);
	}
	public ISurveyChoiceOfPersonDAO getSurveyChoiceOfPersonDAO() {
		return surveyChoiceOfPersonDAO;
	}

	public void setSurveyChoiceOfPersonDAO(ISurveyChoiceOfPersonDAO surveyChoiceOfPersonDAO) {
		this.surveyChoiceOfPersonDAO = surveyChoiceOfPersonDAO;
	}

}
